import { View } from "../../../mvc/core/View";
import { PetUpgradeConfig } from "../../resource/PetUpgradeConfig";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { TPetUpgrage } from "../../../../Message/Db/Tables/TPetUpgrage";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { Language } from "../../../../extend/language/Language";
import { ColorConfig } from "../../resource/ColorConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { PetUtil } from "./info/PetUtil";
type int = number;
//class PetTileListPanel
    
    export  class PetTileListPanel extends View
    {
        constructor(arg1: Boolean)
        {
            super();
            this._bgArray = [];
            this._tileBitmapArray = [];
            this._isGrowth = arg1;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc7=null;
            if (this._isGrowth) 
            {
                this._tilelist = PetUpgradeConfig.instance.growList;
                this._needStrCode = 54555;
                this._descStrCode = 54556;
            }
            else 
            {
                this._tilelist = PetUpgradeConfig.instance.spiritList;
                this._needStrCode = 54557;
                this._descStrCode = 54558;
            }
            var loc6="#00ff00";
            var loc8=0;
            while (loc8 < this._tilelist.length) 
            {
                loc2 = GlobalClass.getBitmap(ImagesConst.PetTileBg);
                loc2.x = loc8 * 145;
                this.addChild(loc2);
                this._bgArray.push(loc2);
                loc1 = this._tilelist[loc8] as TPetUpgrage;
                loc3 = new Object /* flash.display.Bitmap */();
                loc3.x = 5 + loc8 * 145;
                loc3.y = 3;
                this.addChild(loc3);
                this._tileBitmapArray.push(loc3);
                (loc4 = ObjCreate.createTextField("", 35 + loc8 * 145, 5, 100, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280))).autoSize = flash.text.TextFieldAutoSize.LEFT;
                loc4.htmlText = Language.getStringByParam(this._needStrCode, loc1.needNum);
                if (this._isGrowth) 
                {
                    loc7 = loc1.addNum.toString();
                }
                else 
                {
                    loc7 = loc1.addNum + "%";
                }
                loc6 = ColorConfig.instance.getItemColorString(loc1.color);
                (loc5 = ObjCreate.createTextField("", 35 + loc8 * 145, 25, 100, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280))).autoSize = flash.text.TextFieldAutoSize.LEFT;
                loc5.htmlText = HTMLUtil.addColor(Language.getStringByParam(this._descStrCode, loc7), loc6);
                if (loc8 != (this._tilelist.length - 1)) 
                {
                    ObjCreate.createBg(145 + loc8 * 145, 0, 50, 1, this, ImagesConst.SeptalLine).rotation = 90;
                }
                ++loc8;
            }
            LoaderHelp.addResCallBack(ResFileConst.petInfo, this.onCreateTileBitmapHandler);
            return;
        }

        public selectByGrade(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._bgArray.length) 
            {
                loc1 = this._bgArray[loc2] as Object /* flash.display.Bitmap */;
                if (loc2 != (arg1 - 1)) 
                {
                    loc1.bitmapData = GlobalClass.getBitmapData(ImagesConst.PetTileBg);
                }
                else 
                {
                    loc1.bitmapData = GlobalClass.getBitmapData(ImagesConst.PetTileSelectBg);
                }
                ++loc2;
            }
            return;
        }

        /* internal  */onCreateTileBitmapHandler(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            while (loc3 < this._tilelist.length) 
            {
                loc1 = this._tilelist[loc3] as TPetUpgrage;
                loc2 = this._tileBitmapArray[loc3] as Object /* flash.display.Bitmap */;
                loc2.bitmapData = PetUtil.getTileBitmap(loc1.grade, this._isGrowth).bitmapData;
                ++loc3;
            }
            return;
        }

        /* internal */ /* var */_tilelist: Array<any>;

        /* internal */ /* var */_bgArray: Array<any>;

        /* internal */ /* var */_tileBitmapArray: Array<any>;

        /* internal */ /* var */_needStrCode: int;

        /* internal */ /* var */_descStrCode: int;

        /* internal */ /* var */_isGrowth: Boolean;
    }
